#include<iostream>
#include<string> 
using namespace std;

int main()
{
	string all,you;
	while(cin>>all)
	{
		cin>>you;
		string::iterator p;
		switch (you.length())
		{
		case 1:
			if(all[all.length()-1]>you[0])cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			break;
		case 2:
			for(p=all.begin();p!=all.end()-1;p++)
			{
				if(*p>you[0])
				{
					if(*p==*(p+1))
					{	
						cout<<"YES"<<endl;	
						break;	
					}				
				}
			}
			if(p>=all.end()-1)cout<<"NO"<<endl;
			break;
		case 3:
			for(p=all.begin();p!=all.end()-2;p++)
			{
				if(*p>you[0])
				{
					if(*p==*(p+2))
					{
						cout<<"YES"<<endl;	
						break;
					}
				}
			}
			if(p>=all.end()-2)cout<<"NO"<<endl;
			break;
		case 4:
			for(p=all.begin();p!=all.end()-3;p++)
			{
				if(*p>you[0])
				{
					if(*p==*(p+3))
					{
						cout<<"YES"<<endl;	
						break;
					}
				}
			}
			if(p>=all.end()-3)cout<<"NO"<<endl;
			break;
		case 5:
			int ok=0;
			char i;
			for(i=you[0]+1;i<='5';i++)
			{
				int j=0;
				for(p=all.begin();p!=all.end();p++)
				{
					if(*p==i+j)j++;
				}
				if(j>=5){	cout<<"YES"<<endl;	break;	}
			}
			if(i>'5')cout<<"NO"<<endl;
			break;
		}
	}
	return 0;
}